package com.tigercel.xiangchengyun.adapter

import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.ImageView

import com.bumptech.glide.Glide
import com.tigercel.xiangchengyun.R
import com.tigercel.xiangchengyun.utils.Global


/**
 * Created by wqj on 2018/5/30.
 */
class ReportListAdapter(private val mContext: Context, private val imgs: List<String>) : BaseAdapter() {

    override fun getCount(): Int {
        return imgs.size
    }

    override fun getItem(position: Int): Any {
        return position
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
        var convertView = convertView
        val viewHolder: ViewHolder
        if (convertView == null) {
            viewHolder = ViewHolder()
            convertView = View.inflate(mContext, R.layout.item_imgs, null)
            viewHolder.img = convertView!!.findViewById(R.id.list_img)
            convertView.tag = viewHolder
        } else {
            viewHolder = convertView.tag as ViewHolder
        }
        Glide.with(mContext).load(Global.ImgBaseUrl + imgs[position]).into(viewHolder.img!!)
        return convertView
    }

    internal class ViewHolder {
        var img: ImageView? = null
    }
}
